#ifndef PhysicsGeometry_OBJECTS_H
#define PhysicsGeometry_OBJECTS_H

#ifndef M_PI
#define M_PI       3.14159265358979323846
#endif

#ifndef M_PI_2
#define M_PI_2     1.57079632679489661923
#endif

#ifndef M_PI_4
#define M_PI_4     0.785398163397448309616
#endif

#ifndef CONSTRAINT_DEBUG_SIZE
#define CONSTRAINT_DEBUG_SIZE 0.2f
#endif


#define ACTIVE_STATE 1
#define IN_ACTIVE_STATE 0

#include <vector>
#include <map>
#include "OpenGL.h"


#include "btBulletDynamicsCommon.h"

using namespace std;

class pgObjects{
public:
	enum{
		TYPEID_SPACESHIP=1,
		TYPEID_RAGDOLL=2
	};

public:
	//physics 
	static btVector3 p_worldAabbMin, p_worldAabbMax; 
	static btBroadphaseInterface* p_broadPhase; 
	static btDefaultCollisionConfiguration* p_collisionConfiguration;
	static btCollisionDispatcher* p_dispatcher;
	static btSequentialImpulseConstraintSolver* p_solver;
	static btDiscreteDynamicsWorld* p_dynamicsWorld;
	static btAlignedObjectArray<btCollisionShape*>	p_collisionShapes;

	//initialize physics object
	static void InitBulletPhysics(); 
	static void ExitBulletPhysics();
	static btRigidBody* localCreateRigidBody(btScalar mass, const btTransform& startTransform, btCollisionShape* shape,int addToWorld=1);

	static void renderScene();

	//all the existing objects 
	bool isActive;
	static multimap<int,pgObjects*> pgObjectsMap;
	virtual void setObjectState(int state) = 0;

public:
	pgObjects();
	~pgObjects(){}

	//obsolete?
	float yRot;

	btVector3 position;
	btQuaternion orientation;
	btVector3 extents;

	//obsolete?
	void setObjectPositionAndOrientation(float x1,float y1,float z1,float angle);

	//first one doesn't do anything; second draws at pos and orientation of physics.
	virtual void drawGeometry(GLuint render_mode) = 0;
	//int drawGeometry(btRigidBody *thisObjectBody);
};

#endif				